<template>
	<view class="content">
		<view class="search-header">
			<Search class="search" :focus="true" @confirm="onSearch"></Search>
			<label class="cancel-btn" @click="onCancelBtn">取消</label>
		</view>
		<view class="demand-list">
			<view class="demand-item" v-for="(item,i) in demandList" :key="i">
			<DemandItem v-if="item.type=='demand'" :searchValue="searchValue" :options="item" @click="goDetail(item)"></DemandItem>
			<ServiceItem v-if="item.type=='user'" :searchValue="searchValue" :options="item" @click="goDetail(item)"></ServiceItem>
			</view>
		</view>
	</view>
</template>

<script>
	import Search from '../../components/search.vue';
	import DemandItem from '../../components/demand-item.vue'
	import ServiceItem from '../../components/service-item.vue'
	export default {
		components:{
			Search,
			DemandItem,
			ServiceItem
		},
		data(){
			return{
				searchValue:"",
				demandList:[],
			}
		},
		methods:{
			onSearch:function(e){
				console.log(e.value)
				this.searchValue = e.value;
				for (var i = 0; i <10; i++) {
					this.demandList.push({
						type:"demand",
						id:i,
						title:"招聘派单员",
						userName:"刘小云",
						company:"成都壹贰叁文化有限公司",
						companyIcon:"/static/images/logo.png",
						num:"2",
						time:"2021-07-28",
						typeName:"市场推广"
					}),
					this.demandList.push({
						type:"user",
						id: i,
							serviceIcon: "url",
							userIcon: "url",
							userName: "王何伟",
							userJob: "策划专员",
							company: "成都壹贰叁文化有限公司成都壹贰叁文化有限公司",
							score: 4.5,
							tipsList: [
								"PPT", "商业计划书", "小程序开发"
							],
							content: "本人性格热情开朗,待人友好,为人诚实谦虚。工作勤奋,认真负责,能吃本人性格热情开朗,待人友好,为人诚实谦虚。工作勤奋,认真负责,能吃"
						
					})
				}
			},
			onCancelBtn:function(e){
				uni.navigateBack();
			},
			goDetail(e){
				if(e.type=="demand"){
					uni.navigateTo({
						url:'./detail'
					})
				}else if(e.type=="user"){
					uni.navigateTo({
						url:'../service/userCard'
					})
				}
			}
		}
	}
</script>

<style>
	.cancel-btn{
		color: #1371FF;
		font-size: 24rpx;
		width: 88rpx;
		line-height: 56rpx;
		text-align: center;
	}
</style>
